import * as actionTypes from "./contstants.js";

const initialState = {
  currentPage: 0, //当前页码
  pageSize: 20, // 每页展示数据
  roomList: [], // 列表数
  totalCount: 0, // 总数
  isLoading:false, // 列表加载loading
};

function reducer(state = initialState, action) {
  switch (action.type) {
    case actionTypes.CHANGE_CURRENT_PAGE:
      return { ...state, currentPage: action.currentPage };
    case actionTypes.CHANGE_ROOM_LIST:
      return { ...state, roomList: action.roomList };
    case actionTypes.CHANGE_TOTAL_COUNT:
      return { ...state, totalCount: action.totalCount };
    case actionTypes.CHANGE_LOADING:
      return { ...state, isLoading: action.isLoading };
    default:
      return state;
  }
}

export default reducer;
